﻿extjsbase.skin={
	skinID:0,
	init:function(){ 
		var n = Ext.get("skin-style");
        for(var i=0;i<5;i++)
        {
            if(parseInt(Jaf.skin.skinID)==i)
            {                        	
                 var c = document.createElement("<img id=\"imgkin"+i+"\"  width=\"12\" height=\"12\" alt=\"\" onclick=\"Jaf.skin.setskin("+i+")\" \/>");
            	 c.src = "images/skin/c"+i+"_1.gif"; 
            	 n.appendChild(c);
            }
            else
            {
                var c = document.createElement("<img id=\"imgkin"+i+"\"  width=\"12\" height=\"12\" alt=\"\" onclick=\"Jaf.skin.setskin("+i+")\" \/>");
            	c.src = "images/skin/c"+i+"_0.gif"; 
            	n.appendChild(c);
            }
        }
		Jaf.skin.skinID=0; 
	},
	changecss:function (name)
    {
       var date=new Date();
       date.setTime(date.getTime()+30*24*3066*1000);
       document.getElementsByTagName("link")[3].href="ext/resources/css/"+name;
       document.cookie="css="+name+";expires="+date.toGMTString();//设置cookies
    },
	setskin:function (i)
    {
    	//debugger
        var pattern = /[0-4]/;
        if(pattern.test(i))
        {
            
            for(j=0;j<5;j++)
            {
                var imgkin = document.getElementById("imgkin"+j);
                imgkin.src = "images/skin/c"+j+"_0.gif"; 
            }
            var imgkin = document.getElementById("imgkin"+i);
            imgkin.src = "images/skin/c"+i+"_1.gif";
            switch(i){
            	case 0:
            	this.changecss('');
            	break;
            	
            	case 1:
            	 this.changecss('xtheme-olive.css');
            	break;
            	
            	case 2:
            	this.changecss('xtheme-gray.css');
            	break;
            	
            	case 3:
            	this.changecss('xtheme-purple.css');
            	break;
            	
            	case 4:
            	 this.changecss('xtheme-darkgray.css');
            	break;
            	
//            	case 5:
//            	this.changecss('xtheme-vista.css');
//            	break;
            }
          }
    }
	
}